perm filename A84.TEX[106,PHY] blob
sn#826048 filedate 1986-10-08 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 \magnification\magstephalf
C00013 ENDMK
C⊗;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
\baselineskip 14pt
\rm
\parskip 6pt
\line{\sevenrm a84.tex[106,phy] \today\hfill}
\bigskip
\line{\bf Files (I).\hfil}
\medskip
\line{\it ``One Man's Ceiling is Another Man's Floor''\hfill}
Pascal was originally designed for use on computers which communicate
with people and with other machines by {\sl files\/}, sequences of
characters from a standard keyboard recorded on magnetic tape, punched
paper, or analogous media. The assumption was that information to be
processed by a~Pascal program would first be entered into a file,
perhaps by a~human typing at a keyboard, and that information produced
by a~program would go to a~file, perhaps for later printing on paper
by a mechanical printer. As time passed, Pascal was modified to allow
more direct communication between people and programs, but the simplest
programs use files, and we start with them.
If John Doe rents an apartment from Jane Smith, they usually agree to the
terms of a standard contract called a lease, in which the owner is referred
to as Lessor and the renter as Lessee. By using these standard names, the
same lease agreement may be used for thousands of contracts, eliminating
legal fees, typing costs, etc. While John Doe calls himself Lessee in the
contract, he does not change his name to Lessee; everywhere outside the
contract, he is still called John Doe. In the terminology of computing,
he has (in the lease) an {\sl external name\/} John Doe, and an
{\sl internal name\/} Lessee. It is important that the external name
(at least, when Doe writes it by hand) uniquely identify him, and
equally important that the internal name can be used by anyone
who wants to lease an apartment. When Doe and Smith sign the lease,
they enter their (external) names in a standard place that identifies
them with the internal names:
{\narrower\smallskip\noindent
``\undertext{Jane Smith}, hereinafter known as Lessor, and
\undertext{John Doe}, hereinafter known as Lessee, agree as follows: \dots''
\smallskip}
Other examples of unique external names in everyday life are social
security and passport numbers, vehicle identification and license numbers,
and lottery ticket numbers. Names internal to a~legal document,
a~conversation, a~social context, or the like include nicknames,
pronouns, and r\↑ole names like Hamlet and The Commissioner of Police.
People and other entities may have many internal names for different contexts.
Pascal is designed on the assumption that files have internal and external
names, and that a program refers to a file by an internal name. When
a~program is used the user provides an external name for each internal
name, but the writer of the program need not know anything about the
external names. All internal names that correspond to external names appear
in the program heading. If the heading of the program is
{\obeylines\obeyspaces\let =\ \tt
PROGRAM A( B, C );
}
\noindent
the program itself has internal name {\tt A}, and uses files with internal
names {\tt B} and~{\tt C}. Execution of the program begins by acquiring
external names, perhaps {\tt PROGA.DATA} and {\tt PROGA.OUTPUT},
from the user; the program
then might take data from {\tt PROGA.DATA} and put results into
{\tt PROGA.OUTPUT}. The external name of the program itself is usually
established by the context. Reasons for this system are:
\disleft 25pt:
(1): You may want to execute the same program several times, and keep all
the output files; they need distinct names.
\disleft 25pt:
(2): You may want to execute different programs, all of which call their
result files {\tt OUTPUT}, and keep all the output files; again, they need
distinct names.
\disleft 25pt:
(3): The system for naming files varies from one computer to another. The
Pascal standard can't accomodate all of them. At Stanford LOTS, for example,
an external file
name has two parts, separated by periods.
\disleft 25pt:
(4): An output file may be printed, viewed on a terminal screen, sent to
remote places by electronic mail, copied to magnetic tape for an archive,
or saved for later reference.
\smallskip
Programs are often abbreviated by a convention that certain operations on
files have a preferred internal name, used if no other is explicitly
specified. A~preferred name that can be omitted from explicit mention is
called a {\sl default\/}. In particular, all operations by which a Pascal
program writes information on a file use the default internal name
{\tt OUTPUT}, and operations by which a~Pascal program takes information
from a file use the default internal name {\tt INPUT}. Simple programs are
therefore usually written with headings of the forms
{\obeylines\obeyspaces\let =\ \tt
PROGRAM {\rm programname} (OUTPUT);
}
\noindent
or
{\obeylines\obeyspaces\let =\ \tt
PROGRAM {\rm programname} (INPUT, OUTPUT);
}
\noindent
The default file names {\tt INPUT} and {\tt OUTPUT} are assumed to
designate files that contain
{\it text,\/} i.e., sequences of keyboard symbols.
Careful choice of external names can be helpful in managing large collections
of programs and data. I~give, say, the name {\tt SQUARE} to the problem of
finding how many ways there are for $n$~perfect squares to add up to~$s$.
I~give variations on this name to all files relating to the problem:
my Pascal program is {\tt SQUARE.PAS}, the (binary) machine language
program is {\tt SQUARE.BIN}, the input data file containing~$n$ and~$s$
is {\tt SQUARE.DAT}, and the output file is {\tt SQUARE.OUT}. Among the
advantages:
\disleft 25pt:
(1): When I see or remember one of these names, I~know all the others.
If I~find a yellowed printout of {\tt SQUARE.OUT}, I~can determine
what it means by reading the comments in {\tt SQUARE.PAS}.
\disleft 25pt:
(2): The directory of my files is maintained by the computer in alphabetical
order, so the four files are probably listed together.
\disleft 25pt:
(3): The operating system of the computer I use recognizes that a program
name ending in {\tt .PAS} should be translated by the Pascal translator.
\disleft 25pt:
(4): I can delete all these programs by a single command to the computer's
operating system ({\tt DELETE SQUARE.*} at Stanford's LOTS); similarly
I~can print them all, mail them all, etc.
\medskip
\parindent 0pt
\copyright 1985 Robert W. Floyd; First draft (not published) April 8, l985.
%\line{First draft (not published) April 8, l985.
%revised: October 2, 1985; subsequently revised.\hfill}
\bye